06. Transistor Switch Circuit

Transistor Switch Circuit

Transistor Switch Circuit

Add a Software Controlled Transistor Switch

To control the LED through software, add a transistor switch circuit to one of the GPIO pins. Choose an NPN transistor such as the 2N2222A or equivalent and a base resistor to limit the current going through it.

Check the Data Sheet

Whichever transistor you choose, find the matching data sheet to determine the V_{BE} saturation voltage and the required I_B saturation current.

The saturation gain, which may be listed as beta or h_{FE} or simply as a ratio, is used to specify I_B for the design.

Here’s the data sheet for the 2N2222A. In this data sheet, V_{BE} must be at least 0.6V to saturate the transistor. Saturation of the transistor will allow current to flow from the collector to the emitter and turn the LED on. Typically, a value of 0.7V is used.

The gain, h_{FE} is another value we need, but this value is widely variable depending on temperature, current, and operating region. Since this circuit will only use the transistor as a switch and will operate in the Saturation Region when “on”, we want to design the circuit based on the minimum gain that occurs during saturation.

Transistors of this type typically have a saturated gain of 10 or 20, and this value can be found in the data sheet by looking closely at the V_{BE} saturation graph. Recall that the gain is the same as the ratio of the collector to base currents.

Example Switch Resistor Value

To calculate the design value for the base resistor, RB, we need the voltage and current going through it when it is on, in order to calculate the resistance using Ohm’s Law (V = IR ).

From Kirchhoff’s Voltage Law:

V_R = 3.3V - V_{BE} = 2.6V

The resistor current is the same as the base current, I_B , which is calculated using the gain and the collector current. The collector current, I_C , is the same as the current going through the LED, or 20mA in the yellow LED example.

I_R = I_B = 20mA/10 = 0.002A

Therefore, by Ohm’s Law:

R_B = 2.6V/0.002A = 1300\Omega

Transistor Switch Resources:

Quiz 3: Base Current

If the transistor has a saturation gain of 20, and an IC of 30mA, what base current, IB, should be specified to guarantee saturation of the circuit?

SOLUTION: 0.0015A

Quiz 4: Base Resistor

QUESTION:

If you were to use an NPN transistor in the circuit above with VBE(SAT)=0.8, a beta of 20, and an IC of 20mA, what would the calculated value of the resistor (RB) be? (provide answer in ohms)

SOLUTION:

NOTE: The solutions are expressed in RegEx pattern. Udacity uses these patterns to check the given answer